package cn.tradewin.advisor.pages.master;

import java.util.List;

import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

import cn.tradewin.advisor.persist.model.Department;
import cn.tradewin.advisor.persist.services.DeptService;

public class DeptBoard {

	@Inject
	private BeanModelSource beanModelSource;
	
	@Property
	private BeanModel<Department> beanModel;

	@Inject
	private DeptService deptService;

	@Property
	private List<Department> depts;

	@Property
	private Department dept;

	@Inject
	private Messages messages;

	void setupRender() {
		beanModel = beanModelSource.createDisplayModel(Department.class, messages);
		beanModel.add("action", null);
		beanModel.include("sname", "name", "ownerName","action");
		beanModel.get("sname").sortable(false);
		beanModel.get("name").sortable(false);
		beanModel.get("ownerName").sortable(false);
	}
	
	void onPrepareForRender() {
		this.depts = deptService.getAllDepts();
	}
}